package gridmath;

import preprocessing.WindowingSystem;
import datastructures.UserParameters;

public class SearchAreaCalculator extends CaseMatrixBase {

	private final double sensitivity;
	private final int strength;
	private final long t;
	
	
	public SearchAreaCalculator (UserParameters userparams, WindowingSystem windowmaker, int k, int trials) {
		super(windowmaker, userparams.getMaxorder());
		sensitivity = userparams.getPower(); 
		t = trials;
		strength = k;
		
		specialTypeOfOperation = MatrixOperations.calculateSearchArea;
		specialTypeOfOperand = MatrixOperations.calculateNeededCases;
	}

	public double doOperation (double pAtCoordinate) {		
		double pk = Math.pow ( pAtCoordinate , strength );
		double prob = 1 - Math.pow ( (1-pk), t );
		return ( prob > sensitivity ) ? prob : 0;
	}
	
	public long getNumberOfTrials() {
		return t;
	}	
	
}
